$.ajaxSetup({
    headers:{
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});
$(".post-audit").click(function(event){
    target = $(event.target);
    var post_id = target.attr("post-id");
    var status = target.attr("post-action-status");
    $.ajax({
        url:"/admin/posts/"+ post_id + "/status",
        method:"POST",
        data:{"status":status},
        dataType:"json",
        success:function(data){
            if(data.error != 0){
                alter(data.msg);
                return;
            }
            target.parent().parent().remove();
        }
    });

});

$(".resource-delete").click(function(event){
    layer.confirm('您确定要删除吗？', {
        btn: ['确定','取消'] //按钮
    }, function(){
    var target = $(event.target);
    event.preventDefault();
    var url = $(target).attr("delete-url");
    $.ajax({
        url:url,
        method:"POST",
        data:{"_method":"DELETE"},
        dataType:"json",
        success:function(data){
            if(data.status == 0){
                layer.alert(data.msg, {icon: 6});
            }
            window.location.reload();
        }
    });});
});

$(".notice-delete").click(function(event){
    layer.confirm('您确定要删除吗？', {
        btn: ['确定','取消'] //按钮
    }, function(){
        var target = $(event.target);
        event.preventDefault();
        var url = $(target).attr("delete-url");
        $.ajax({
            url:url,
            method:"POST",
            data:{"_method":"DELETE"},
            dataType:"json",
            success:function(data){
                if(data.status == 0){
                    layer.alert(data.msg, {icon: 6});
                }
                window.location.reload();
            }
        });});
});